﻿using System.Collections.Generic;
using System.Linq;
using GuRenFang.Service.Entity;
using GuRenFang.Service.IDa;

namespace GuRenFang.Da
{
   public class PackagesRepository: RepositoryBase<Packages>, IPackagesRepository
    {
        public PackagesRepository(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
        {
            
        }

       public IEnumerable<Packages> GetPackagesByPages(int pageIndex, int pageSize, string orderFiled, out int totalRecord)
       {
           var startRecord = pageSize * (pageIndex - 1);
           totalRecord = DataContext.Packages.Count();
           return this.DataContext.Packages.OrderBy(n => n.Price).Skip(startRecord).Take(pageSize);
       }
    }
}
